
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$title="Thêm danh muc bài viết";


require '../layout/headeradmin.inc';

if(isset($_POST['sua-cate']))
{
    $name_cate=  trim($_POST['name-cate']);
    $parent_id=  trim($_POST['parent_id']);
    $note_cate=  trim($_POST['note_cate']);
    $description_cate=trim($_POST['description_cate']);
     if(get_magic_quotes_gpc())
    {
         $name_cate=  trim(mysqli_real_escape_string($_POST['name-cate']));
    $parent_id=  trim(mysqli_real_escape_string($_POST['parent_id']));
    $note_cate=  trim(mysqli_real_escape_string($_POST['note_cate']));
    $description_cate=trim(mysqli_real_escape_string($_POST['description_cate']));
    
       
    }
//    insertCate($parent_id,$title,$note,$description)
    $k->insertCate($parent_id, $name_cate,$note_cate,$description_cate);
    header("Location: home.php");

}
 else {
    

?>
<script src="../plugin/ckeditor_4.4.4_full/ckeditor/ckeditor.js" type="text/javascript"></script>


<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <fieldset>
        <legend><text>Thêm danh mục bài viết</text></legend>
        <table id="t-adduser">
            <tbody>
                <tr>
                    <td><label>Tên danh mục</label></td>
                    <td><input type="text" id="name-cate" name="name-cate"></td>
                </tr>
<!--                 <tr>
                    <td><label>ckeditor</label></td>
                    <td><textarea row="4" cols="100" class="ckeditor" name="eddd" ></textarea></td>
                </tr>-->
                <tr>
                    <td><label>Danh mục cha</label></td>
                    <td>
                        
                        <?php 
//                        echo mysqli_num_rows($k->getCateParent());
//                        if(mysqli_num_rows($k->getCateParent())>0)
//                        {
//   
                            ?>
                            <select id="se" name="parent_id">
                           <option value="0">Danh mục gốc</option>
                                <?php 
                                
                                    $data=$k->getCateParent();
                                    echo mysqli_num_rows($data);
                                   while ($row = mysqli_fetch_array($data)) {
                                        
                                 
                                
                                
                                ?>
                                <option value="<?php echo $row['id'];?>"><?php echo $row['name_cate']; ?></option>
                          
                            
                        
                        <?php 
//                           }
                        }
// else {
//     
// }
                        ?>
                                </select>
                    </td>
                </tr>
                 <tr>
                    <td><label>Ghi chú</label></td>
                    <td><textarea row="4" cols="100"  id="note-cate" name="note_cate"></textarea></td>
                </tr>
                 <tr>
                    <td><label>Miêu tả</label></td>
                    <td><textarea row="4" cols="100"  id="description-cate" name="description_cate"></textarea></td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align: center;" >
                        <div>
                            <input type="submit" name=sua-cate" value="Thêm" >
                            <input type="button" name="huy" value="Hủy" >
                        </div>
                    </td>
                </tr>
            </tbody>
            <tfoot>
                
            </tfoot>
        </table>
    </fieldset>
</form>



<?php
 }
require '../layout/footeradmin.inc';
?>